"""
需求:进入系统后显示系统功能界面
1.添加学员
2.删除学员
3.修改学员信息
4.查询学员信息
5.显示所有学员信息
6.退出系统
"""

info = []  # 学员信息列表


# 功能界面
def info_print():
    print(
        """
请选择功能:
-----------------
    1.添加学员
    2.删除学员
    3.修改学员
    4.查询学员
    5.所有学员
    6.退出系统
-----------------
        """)


# 添加学员信息
def add_info():
    """添加学员函数"""
    new_id = input("学号：")
    global info
    for i in info:
        if new_id == i['id']:
            print("学号已存在")
            return
    new_name = input("姓名：")
    new_tel = input("手机号：")

    new_info = {'id': new_id, 'name': new_name, 'tel': new_tel}
    info.append(new_info)
    print(info)


# 删除学员信息
def delete_info():
    """删除学员信息"""
    info_id = input("请输入要删除的学员id：")
    global info
    for i in info:
        if i["id"] == info_id:
            info.remove(i)
            print("删除成功")
            return
    print("不存在此学号")
    return


# 修改学员信息
def update_info():
    """修改学员信息"""
    info_id = input("请输入要修改的学员id：")
    global info
    for i in info:
        if i["id"] == info_id:
            i["name"] = input("姓名：")
            i["tel"] = input("手机号：")
            print("修改成功")
            return
    print("不存在此学号")
    return


# 查询学员
def find_info():
    """查询学员"""
    info_id = input("请输入要查询的学员id：")
    global info
    for i in info:
        if i["id"] == info_id:
            print(i)
            return
    print("不存在此学号")
    return


# 所有学员
def all_info():
    """所有学员信息"""
    global info
    for i in info:
        print(i)
    return


info_print()

while True:
    user_num = int(input('请输入功能序号：'))

    if user_num == 1:
        add_info()
    elif user_num == 2:
        delete_info()
    elif user_num == 3:
        update_info()
    elif user_num == 4:
        find_info()
    elif user_num == 5:
        all_info()
    elif user_num == 6:
        break
    else:
        print("输入的功能序号有误")
        info_print()
